package com.ln.core.security.entity;

import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.ln.core.orm.hibernate.BaseEntity;

@Entity
@Table(name = "roles")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Roles extends BaseEntity {

	private String name;
	private boolean enable;
	private String type;

	@ManyToMany(targetEntity = Resources.class, fetch = FetchType.LAZY)
	@JoinTable(name = "roles_resources", joinColumns = @JoinColumn(name = "rid"), inverseJoinColumns = @JoinColumn(name = "reid"))
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	private Set<Resources> resources;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public boolean isEnable() {
		return enable;
	}

	public void setEnable(boolean enable) {
		this.enable = enable;
	}

	public Set<Resources> getResources() {
		return resources;
	}

	public void setResources(Set<Resources> resources) {
		this.resources = resources;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

}
